#include "map.h"
#include <fstream>

Map::Map(){}

void Map::load(char * a_filename)
{
	fstream in(a_filename);
	in >> m_height;
	in >> m_width;
	in.ignore();
	m_map = new char * [m_height];
	for(int h = 0; h < m_height; ++h)
	{
		m_map[h] = new char[m_width];
		for(int w = 0; w < m_width; ++w)
		{
			m_map[h][w] = in.get();
		}
		in.ignore();
	}
}

int Map::getWidth()
{
	return m_width;
}

int Map::getHeight()
{
	return m_height;
}

char Map::getAt(int a_x, int a_y)
{
	return m_map[a_y][a_x];
}

char Map::setAt(int a_x, int a_y, char a_c)
{
	return m_map[a_y][a_x] = a_c;
}

	////=========IMAGE ASSIGNMENT==================

	//initializeImages();

	////=======TextMapImageStuff====================
	//textColor.r = 255;//yellowish text for now 255,255,9
	//textColor.g = 255;
	//textColor.b = 9;

	//font = NULL;
	//resourceListMsg[0] = NULL;
	//resourceListMsg[1] = NULL;
	//resourceListMsg[2] = NULL;
	//resourceListMsg[3] = NULL;
	//resourceListMsg[4] = NULL;

///////////////////////////////////////
	//playerTag = NULL;


////////////////////////////////////
Map::~Map()
{
	for(int h = 0; h < m_height; ++h)
	{
		delete m_map[h];
	}
	delete m_map;
	m_map = 0;
	m_height = 0;
	m_width = 0;
}
